package part_3;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Strings {
	public static void main(String[] args) throws IOException {
		//make an inputbuffer
		BufferedReader inputbuffer = new BufferedReader(new InputStreamReader(System.in));
		
		//make some other vars
		String date; 
		int[] dateFormated = new int[3];
		String[] monthNames = {"January","February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
		
		boolean noerror = true;
		do{
			//get the date
			System.out.println("input date {format: 20-12-92}:");
			date = inputbuffer.readLine();
			
			//convert the date to something sensable
			StringTokenizer Tokenizor = new StringTokenizer(date, "-");
			dateFormated[0] = Integer.parseInt(Tokenizor.nextToken());
			dateFormated[1] = Integer.parseInt(Tokenizor.nextToken());
			dateFormated[2] = Integer.parseInt(Tokenizor.nextToken());
			
			//  check if the date is correct
			//	check day ------------------------------------> check month -------------------------------> check year -------------------------------------> 
			if (dateFormated[0] > 0 && dateFormated[0] <= 31 && dateFormated[1] > 0 && dateFormated[1] <= 12 && dateFormated[2] < 100 && dateFormated[2] >= 0) {
				noerror = false;
			} else {
				dateFormated[0] = dateFormated[1] = dateFormated[2] = 0;
			}
		} while(noerror);
		
		//convert the year format
		if(dateFormated[2] < 80){
			dateFormated[2] += 2000; 
		} else {
			dateFormated[2] += 1900;
		}
		
		//dump date
		System.out.println("The date is now:" + " " + dateFormated[0] + " " + monthNames[dateFormated[1]-1] + " " + dateFormated[2]);
	}
}
